+ Reply to Thread
Page 1 of 6 1 2 3 ... LastLast
Results 1 to 10 of 53

Thread: CTL strategies i write

  1. #1

    CTL strategies i write

    Hey guys i am publishing some CTL strategies examples. Any advice how to improuve them is welcome. You can take a look at them on the following blog

    http://ctltrading.blogspot.com/


  2. #2
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383
    Hi CTL,

    I took a look at your blog. The first question I asked myself was:

    What are all those ads for forex brokers that don't support CTL doing there?
    Cheers,

    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  3. #3
    Hi,

    Yeah i know pretty bad. But google adsense doesn't have any option to avoid that. I try to make a few pennies/year with adsense. I hope you don't mind. I really like the writing of CTL. The strategies aren't copied from an other site. They are built up from scrath by myself. I hope to find and write a real good profitable strategy...hope you wish me luck....

    Anyway if i can help somebody that has problems with any coding don't hesitate to ask for help....i wil do my best to help...

    Cya

  4. #4
    Junior Member
    Join Date
    Jan 2011
    Location
    Hungary
    Posts
    16

    Hi Ctl!

    I must say, you made a great thing!
    I'm interested too in programming that, but i'm a beginner on it. So at first i will test yours in a demo account, and see it. I have protrader station.
    In the chart studio i had a problem with the Candle pattern strategy. It says that Max_allowed_loss=-100 is wrong. If i correct it to a positive nuber it's ok. How can i fix it so, that it accepts negative numbers? Or anything else?

    Balu

  5. #5
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383
    Hi Balu,

    Sounds like you're talking about one of CTL's strategies, rather than one of ours!

    If CTL has no objections, maybe you could post the code in question here, so that we can take a look at it?

    Cheers,

    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  6. #6
    Junior Member
    Join Date
    Jan 2011
    Location
    Hungary
    Posts
    16
    Hi Jim!

    the code from ctl:
    I have underlined, and set to red the wrong tile. It seems, that it works only with positive numbers....


    Code:
    strategy candle_pattern_strategy;
    /* written by ctlprogrammer for EUR/USD */
    /*Warning for demonstration purpose only, no live trading please*/
    /*you can freely copy the code but plz leave this header*/
    /*www.ctltrading.blogspot.com*/
    input lots = 1,tradingallowed = false,Max_allowed_loss=-100,profit_taking_level=100;
    vars currentbar(number), maint(series),maout(series),periodATR=14,possible_sell(bool),possible_buy(bool);
    begin
    /*every candle tells his story*/
    currentbar := back(close);
    if currentbar < 200 then return;
    bollinger_bands();
    Average_True_Range();
    Fast_Stochastics();
    Relative_Strength();
    Mov_Avg_Exponential(close,200);
    possible_buy:=false;
    possible_sell:=false;
    /*BULLISH red hammer in downtrend*/
    if close[currentbar]<open[currentbar] and
    (high[currentbar]-open[currentbar])<0.00002 and
    (open[currentbar]-close[currentbar])*2 < (close[currentbar]-low[currentbar]) and
    close[currentbar-1]<open[currentbar-1] and 
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75
    then 
    begin
      alert("text","bullish red hammer in a downtrend");
      possible_buy:=true;  
    end;
    /*BULLISH green hammer in downtrend*/
    if close[currentbar]>open[currentbar] and
    (high[currentbar]-close[currentbar])<0.00002 and
    (close[currentbar]-open[currentbar])*2 < (open[currentbar]-low[currentbar]) and
    close[currentbar-1]<open[currentbar-1] and 
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75
    then 
    begin
      alert("text","bullish green hammer in a downtrend");
      possible_buy:=true;   
    end; 
    /*BEARISH green hanging man in uptrend*/
    if close[currentbar]>open[currentbar] and
    (high[currentbar]-close[currentbar])<0.00002 and
    (close[currentbar]-open[currentbar])*2 < (open[currentbar]-low[currentbar]) and
    close[currentbar-1]>open[currentbar-1] and
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75
    then 
    begin
      alert("text","bearish green hanging man in uptrend");
      possible_sell:=true;   
    end; 
    /*BEARISH red hanging man in uptrend*/
    if close[currentbar]<open[currentbar] and
    (high[currentbar]-open[currentbar])<0.00002 and
    (open[currentbar]-close[currentbar])*2 < (close[currentbar]-low[currentbar]) and
    close[currentbar-1]>open[currentbar-1] and
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75 
    then
    begin
      alert("text","bearish red hanging man in uptrend");
      possible_sell:=true;   
    end;
    /*BULLISH engulfing matching low*/
    if close[currentbar]>open[currentbar] and
    close[currentbar-1]<open[currentbar-1] and
    close[currentbar-2]<open[currentbar-2] and
    close[currentbar]>high[currentbar-1] and
    low[currentbar-1]-0.0001 <low[currentbar]and low[currentbar]<low[currentbar-1]+0.0001 and
    close[currentbar-1] -0.0001<open[currentbar]and open[currentbar]<close[currentbar-1]+0.0001 and
    close[currentbar]>open[currentbar-1] and
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75 and
    (high[currentbar-1]-low[currentbar-1]) > Average_True_Range.line[currentbar]*0.75
    then
    begin
      alert("text","bullish engulfing matching low");
      possible_buy:=true;   
    end;
    /*BEARISH engulfing matching high*/
    if close[currentbar]<open[currentbar] and
    close[currentbar-1]>open[currentbar-1] and
    close[currentbar-2]>open[currentbar-2] and
    close[currentbar]<low[currentbar-1] and
    high[currentbar-1]-0.0001 <high[currentbar]and high[currentbar]<high[currentbar-1]+0.0001 and
    close[currentbar-1] -0.0001<open[currentbar]and open[currentbar]<close[currentbar-1]+0.0001 and
    close[currentbar]<open[currentbar-1] and
    (high[currentbar]-low[currentbar]) > Average_True_Range.line[currentbar]*0.75 and
    (high[currentbar-1]-low[currentbar-1]) > Average_True_Range.line[currentbar]*0.75
    then
    begin
      alert("text","bearish engulfing matching high");
      possible_sell:=true;   
    end;
    if tradingallowed=true then 
    begin
    /* this part defines the entries */
    if possible_sell=true and Mov_Avg_Exponential.line[currentbar-1]>Mov_Avg_Exponential.line[currentbar] and
    (Relative_Strength.line[currentbar]>50 or high[currentbar]>Bollinger_Bands.line_upper[currentbar] or Fast_Stochastics.line_k[currentbar]>80) then sell(lots);
    if possible_buy=true and 
    (Relative_Strength.line[currentbar]<50 or low[currentbar]<Bollinger_Bands.line_lower[currentbar] or Fast_Stochastics.line_k[currentbar]<20) then buy(lots);
    /*this part defines the exits */
    if long() and Mov_Avg_Exponential.line[currentbar-1]<Mov_Avg_Exponential.line[currentbar] and
    (Relative_Strength.line[currentbar]>70 or high[currentbar]>Bollinger_Bands.line_upper[currentbar] or Fast_Stochastics.line_k[currentbar]>80) then exitlong();
    if short() and 
    (Relative_Strength.line[currentbar]<30 or low[currentbar]<Bollinger_Bands.line_lower[currentbar] or Fast_Stochastics.line_k[currentbar]<20) then exitlong();
    /*this part defines a basic money mangagment*/
    if fpl()<Max_allowed_loss then
    begin
    if long() then exitlong();
    if short() then exitshort();
    end;
    if fpl()>profit_taking_level then
    begin
    if long() then exitlong();
    if short() then exitshort();
    end;
    end;
       
    end.

  7. #7
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383
    Hi Balu,

    I've taken liberty of wrapping that code up inside some code tags.

    Then I copied it straight into Chart Studio and it built and installed without an error. I'm now running it on a Dealbook chart (in a demo account!) and it seems to be working OK.

    What version of Chart Studio are you using?

    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  8. #8
    Junior Member
    Join Date
    Jan 2011
    Location
    Hungary
    Posts
    16
    Hi Jim,

    I have 1.0.37.14 version.
    How is it working?

  9. #9
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    383
    Hi Balu,

    My version is 1.0.39.14. If yours isn't merely a typo, maybe that's your problem?

    I changed Max_allowed_loss to be a positive number, which is more intuitive anyway, and also changed line 106 to read:

    Code:
    if fpl() < -Max_allowed_loss then
    That seems to work too.

    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  10. #10
    Thks Balu. I am so happy you like it.

    And sure JIM of course the code can be used and showed on this forum. You can even change or improve the code if you want.

    The only thing that i wouldn't like is that somebody would use it unchanged with the header deleted and claiming he wrote it.

    If you are totally new with CTL i advice you start with the examples in the chartstudio help.

+ Reply to Thread
Page 1 of 6 1 2 3 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts