Highest and Lowest of a number of candles: Programming support

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #38495 quote
    Juan Salas
    Participant
    Master

    Hi everyone,

    As you can see, I am new in PRT coding, and I am trying to determine the highest and lowest of the last 16 candles (M15) before 090000 to create a canal, but I don’t really know how to determine these values. I have tried with the function highest and lowest, but I have problems to determine the period from 050000 to 090000. I am feeling embarrassed because it is a simple problem compared to the level of programming I am seeing in the forum, but I would appreciate any help on this.

    Thanks in advance,

    Best, Juan

    #38498 quote
    Despair
    Blocked
    Master
    if time=90000 then
      channelhigh=highest[16](high)
      channellow=lowest[16](low)
    endif

    Maybe like this?

    #38510 quote
    Juan Salas
    Participant
    Master

    Hi Despair,

    Thanks for your prompt reply. I am trying to build a very basic system for FOREX in which building a channel (16 candles of 15min) from 050000am to 090000am, and then wait until any candle after 09:00 breaks (with its candles’s close) the inferior (Lowest) or superior limit (Highest), with the idea to scalp 6-8 pips daily.

    The problem is that the channel seems to be attached to the price. In other words, that at 09:30, 09:45, 10:00, etc the system is still creating a channel with the previous 16 candles. Either that, or that I don’t know how to limit the number of operations.

    I am also trying to limit the operations to 1 a day from 090000 to 140000. But, I don’t know how to limit the entries (long or short) to just one. I have DEFPARAM CumulateORders=False, but the moment that one order is complete, it opens another one.

    I know this is too much to ask, but I am stuck here, trying to find the info on the Internet but the only place I receive any answers is here, from either Nicolas or you.

    Thanks so much in advance,

    Juan

    #38512 quote
    Juan Salas
    Participant
    Master

    Sending the code, I am sure I have screwed it up.

    Screen-Shot-2017-06-17-at-19.27.49.png Screen-Shot-2017-06-17-at-19.27.49.png
    #38519 quote
    Juan Salas
    Participant
    Master

    Hi everyone! Solved the Channel high and low. Thanks Despair. I think I wrote something wrong!!

    Just need to solve the one operation per day. Right now, the system launches one buy/sell after another. I would like to buy or sell on the breakout and that is. I am searching on the topics about this subject, so if anyone can redirect me, I would appreciated it.

    Thanks!!! 🙂

    Juan

    #38520 quote
    enzo_52
    Participant
    Senior

    Hi guys, someone can help me?

    i would say to the TS :

    if i am LONG and time >= 020000 and time<= 040000 close the trade if the price is less then lowest of  ID pattern (high<high[1] and low>low[1]), if between  020000 and 040000 the condition witn ID pattern does not happened , close the trade at 030000

    thanks in advance

    Vincenzo

    #38525 quote
    Despair
    Blocked
    Master

    Juan: Post your code with the <> symbol here not as picture. Then i will fix it. 🙂

    #38529 quote
    Juan Salas
    Participant
    Master
    // FOREX BREAKOUT-15 MIN
    // One order per day, from 09:00h. The system shuts-down at 14:00h
    Defparam cumulateorders = false
    
    //One Trade Per Day
    Once nbTrades = 0
    Once tradesPerDay = 1
     
    If Day<>Day[1] then
    nbTrades = 0
    Else
    If (Not OnMarket[1] and OnMarket) xor (ShortOnMarket[1] and LongOnMarket) xor (LongOnMarket[1] and ShortOnMarket) then
    nbTrades = nbTrades + 1
    Endif
    Endif
     
    If nbTrades < tradesPerDay then
    //End One Trade Per Day Code
    
    // Conditions
    Ctime = TIME > 090000 AND TIME < 140000
     
    // Range between 0500h to 0900h
    IF TIME=090000 AND tradeok=1 THEN
    Channelhigh = Highest[16](high)
    Channellow = Lowest[16](low)
    ENDIF
    //No activity if the channel highest and lowest is >= 32 pips and <= 12 pips
    IF channelhigh-channellow>=32*pipsize OR channelhigh-channellow<= 12*pipsize THEN
    tradeok = 0
    ELSE
    tradeok = 1
    ENDIF
    
    //Conditions for long/short breakout entry
    IF NOT LONGONMARKET AND Ctime AND tradeok = 1 THEN
    IF close > channelhigh THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    ENDIF
    
    IF NOT SHORTONMARKET AND Ctime AND tradeok = 1 THEN
    IF close < channellow THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    ENDIF
    ENDIF
    
    // Stop y profit
    SET STOP Loss 8*pipsize
    SET TARGET PROFIT 8*pipsize
    
    
    
    
    
     
    
     
    

    Hi Despair,

    I am a little dumb today. I am trying to paste the code here as a text, but I got it in black/white, not coloured/linked as in PRT. My Mac does not convert the itf, and I follow the instructions of <> but it is still b/w. :(((((

    As I mentioned, this is my first code. Although I am reading the manuals, there are some specifics that are not mentioned anywhere.

    I am trying to build a simple FOREX Breakout system in TF=15′ with a channel from 05:00 to 09:00h, and then wait until the breakout, and wait for the close of the candle breaks the highest or lowest and will launch an order long or short depending the direction at the beginning of next bar. TP=8, SL=8, as you can see it is not very ambitious, but enough to start practising and learning the ropes.

    The most important is that I want this to happen just once a day. Once breaks and either win or loss, no more operations for the day. The system will shut-down at 14:00h, which gives plenty of room for one single trade. 

    Knowing how to program this simple task, will give me the resources to include other features or ideas in the future.

    The channel seems to work, although I have been trying to include the limitation of one trade per day, and I might screwed up again.

    Any suggestions will be welcome.

    I don’t know how to thank you for this!!! Thanks so much. I owe you big.

    Juan

    #38537 quote
    Despair
    Blocked
    Master
    Defparam cumulateorders = false 
    
    // Conditions
    Ctime = TIME > 090000 AND TIME < 140000 and not onmarket
     
    // Range between 0500h to 0900h
    IF TIME=090000 THEN
    Channelhigh = Highest[16](high)
    Channellow = Lowest[16](low)
    ENDIF
    //No activity if the channel highest and lowest is >= 32 pips and <= 12 pips
    IF channelhigh-channellow>=32*pipsize OR channelhigh-channellow<= 12*pipsize THEN
    notrade=1
    ELSE
    notrade=0
    ENDIF
     
    IF Ctime and not notrade then
     c1=close crosses over channelhigh
     c2=close crosses under channellow
     IF C1 THEN
       BUY 1 contract at market
       notrade=1
     ELSIF C2 THEN
       SELLSHORT 1 contract at market
       notrade=1
     ENDIF
    ENDIF
    
    if time= 140000 then
      if longonmarket then
        sell at market
      elsif shortonmarket then
        exitshort at market
      endif
    endif
    
    // Stop y profit
    SET STOP PLoss 8*pipsize
    SET TARGET PPROFIT 8*pipsize

    Hi Juan,

    I think the code above does what you want (I did not test it though). BTW If you prefer me to answer in german, write in the german forum. 🙂

    #38538 quote
    enzo_52
    Participant
    Senior

    Hi guys, someone can help me? i would say to the TS : if i am LONG and time >= 020000 and time<= 040000 close the trade if the price is less then lowest of ID pattern (high<high[1] and low>low[1]), if between 020000 and 040000 the condition witn ID pattern does not happened , close the trade at 030000 thanks in advance Vincenzo

    sorry, i do a correction :

    if i am LONG and time >= 020000 and time<= 040000 close the trade if the price is less then lowest of ID pattern (high<high[1] and low>low[1]), if between 020000 and 040000 the condition witn ID pattern does not happened , close the trade at 040000

    thanks in advance Vincenzo

    #38540 quote
    Juan Salas
    Participant
    Master

    Hi Despair,

    Thanks a lot for the code and for your effort. I have tested and it seems to be better but all the operations are neutral. I have checked the graphics and all are neutral. And I still launch 2 or 3 buy/sell during the same day.

    In any case, thanks so much for your help. I think I can take it from here. I think it just needs some adjustments, and I hope will have by today or tomorrow. I will let you know the result.

    BTW, thanks for the German offer, but I am Spanish. Just moved to Hamburg few months ago for family reasons, and I am still have a very basic level of German 🙂

    Have a great day!

    Juan

    #38542 quote
    Despair
    Blocked
    Master
    Defparam cumulateorders = false 
     
    // Conditions
    Ctime = TIME > 090000 AND TIME < 140000 and not onmarket
     
    // Range between 0500h to 0900h
    IF TIME=090000 THEN
      Channelhigh = Highest[16](high)
      Channellow = Lowest[16](low)
      //No activity if the channel highest and lowest is >= 32 pips and <= 12 pips
      IF channelhigh-channellow>=32*pipsize OR channelhigh-channellow<= 12*pipsize THEN
        notrade=1  
       ELSE
        notrade=0
       ENDIF
    ENDIF
    
    IF Ctime and not notrade then
     c1=close crosses over channelhigh
     c2=close crosses under channellow
     IF C1 THEN
       BUY 1 contract at market
       notrade=1
     ELSIF C2 THEN
       SELLSHORT 1 contract at market
       notrade=1
     ENDIF
    ENDIF
     
    if time= 140000 then
      if longonmarket then
        sell at market
      elsif shortonmarket then
        exitshort at market
      endif
    endif
     
    // Stop y profit
    SET STOP PLoss 8*pipsize
    SET TARGET PPROFIT 8*pipsize

     

    You are right, the one “endif” was at the wrong place. Now the code shall only take one trade per day.

    #38555 quote
    Juan Salas
    Participant
    Master

    <pre class=”lang:probuilder decode:true “>// FOREX BREAKOUT
    // 15 MIN
    // One order per day, from 09:00h. The system shuts-down at 14:00h
    // Everyday Channel formation from 0500 to 0900 (Highest-Lowest)
    // Maximum-Minimum Channel Amplitude 32pips-12pips

    DEFPARAM CUMULATEORDERS = false

    // OPERATIONAL TIME
    DEFPARAM FLATBEFORE = 090000
    DEFPARAM FLATAFTER = 140000
    Operationaltime = TIME > 090000 AND TIME < 140000

    // ONE TRADE PER DAY. It resets the variable each new day
    IF INTRADAYBARINDEX = 0 THEN
    alreadytraded = 0
    ENDIF

    // RANGE between 0500h to 0900h
    IF TIME=090000 THEN
    channelhigh = Highest[16](high)
    channellow = Lowest[16](low)
    ENDIF

    // NO ACTIVITY if the channel highest and lowest is >= 32 pips and <= 12 pips
    IF channelhigh-channellow>=32*pipsize OR channelhigh-channellow<= 12*pipsize THEN
    tradeok=0
    ELSE
    tradeok=1
    ENDIF

    // BREAKOUT Conditions
    c1= close > channelhigh
    c2= close < channellow

    // LONG Positions-Opening
    IF Operationaltime AND tradeok = 1 AND c1 AND alreadytraded = 0 THEN
    BUY 1 CONTRACT AT MARKET
    tradeok = 0
    alreadytraded = 1
    ENDIF

    // SHORT Positions-Opening
    IF Operationaltime AND tradeok = 1 AND c2 AND alreadytraded = 0 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    tradeok = 0
    alreadytraded = 1
    ENDIF

    // STOP & PROFIT
    SET STOP LOSS 8*pipsize
    SET TARGET PROFIT 8*pipsize

    Hi Despair,

    Now is working perfectly. I have included a different modification that I got from a past post from Nicolas and now only trades once a day.

    Thanks so much for your help!!!

    Juan

    #38556 quote
    Juan Salas
    Participant
    Master
    // FOREX BREAKOUT
    // 15 MIN
    // One order per day, from 09:00h. The system shuts-down at 14:00h
    // Everyday Channel formation from 0500 to 0900 (Highest-Lowest)
    // Maximum-Minimum Channel Amplitude 32pips-12pips
    
    DEFPARAM CUMULATEORDERS = false
    
    // OPERATIONAL TIME
    DEFPARAM FLATBEFORE = 090000
    DEFPARAM FLATAFTER = 140000
    Operationaltime = TIME > 090000 AND TIME < 140000
    
    // ONE TRADE PER DAY. It resets the variable each new day
    IF INTRADAYBARINDEX = 0 THEN
    alreadytraded = 0
    ENDIF
    
    
    // RANGE between 0500h to 0900h
    IF TIME=090000 THEN
    channelhigh = Highest[16](high)
    channellow = Lowest[16](low)
    ENDIF
    
    // NO ACTIVITY if the channel highest and lowest is >= 32 pips and <= 12 pips
    IF channelhigh-channellow>=32*pipsize OR channelhigh-channellow<= 12*pipsize THEN
    tradeok=0
    ELSE
    tradeok=1
    ENDIF
    
    // BREAKOUT Conditions
    c1= close > channelhigh
    c2= close < channellow
    
    // LONG Positions-Opening
    IF Operationaltime AND tradeok = 1 AND c1 AND alreadytraded = 0 THEN
    BUY 1 CONTRACT AT MARKET
    tradeok = 0
    alreadytraded = 1
    ENDIF
    
    // SHORT Positions-Opening
    IF Operationaltime AND tradeok = 1 AND c2 AND alreadytraded = 0 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    tradeok = 0
    alreadytraded = 1
    ENDIF
    
    // STOP & PROFIT
    SET STOP LOSS 5*pipsize
    SET TARGET PROFIT 10*pipsize
    
    
    
     
    
    
    
    
    
     
    
     
    

    I hope that now is coloured!!! 🙂

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Highest and Lowest of a number of candles: Programming support


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Juan Salas @juan-salas Participant
Summary

This topic contains 13 replies,
has 3 voices, and was last updated by Juan Salas
8 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/17/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...