Help debugging code. Not operating everyday. Why???

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #39106 quote
    Juan Salas
    Participant
    Master
    / FOREX BREAKOUT
    // 15 MIN
    // One trade per day, from 08:00h to 14:00. The system shuts-down at 14:00h
    // Everyday Channel formation from 0700 to 0800 (Highest-Lowest)
    // Maximum Range 32pips
     
    DEFPARAM CUMULATEORDERS = false
     
    // OPERATIONAL TIME
    DEFPARAM FLATBEFORE = 080000
    DEFPARAM FLATAFTER = 140000
    Operationaltime = TIME > 080000 AND TIME < 140000
     
    // ONE TRADE PER DAY. It resets the variable each new day
    IF INTRADAYBARINDEX = 0 THEN
    alreadytraded = 0
    reverse = 0
    ENDIF
     
    // RANGE between 0700h to 0800h
    IF TIME=080000 THEN
    channelhigh = Highest[4](high)
    channellow = Lowest[4](low)
    ENDIF
     
    // NO ACTIVITY if the range (highest-lowest)is >= 32 pips
    IF channelhigh-channellow>=32*pipsize THEN
    tradeok=0
    ELSE
    tradeok=1
    ENDIF
     
    // LONG Positions-Opening
    IF NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THEN
    BUY 1 CONTRACT AT channelhigh + 3*pipsize STOP
    alreadytraded=1
    reverse=1
    ENDIF
     
    
    // SHORT Positions-Opening
    IF NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THEN
    SELLSHORT 1 CONTRACT AT channellow - 3*pipsize STOP
    alreadytraded=2
    reverse=1
    ENDIF
     
    
    // TEST IF AN ORDER IS IN THE MARKET
    IF ONMARKET THEN
    tradeok = 0
    alreadytraded = 1
    ENDIF
     
    
     
    // REVERSE
    IF reverse=1 THEN
    IF alreadytraded=1 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    reverse=0
    ENDIF
    IF alreadytraded=2 AND NOT ONMARKET AND POSITIONPERF(1)<0 THEN
    BUY 1 CONTRACT AT MARKET
    reverse=0
    ENDIF
    ENDIF
     
    // STOP & PROFIT
    SET STOP LOSS 5*pipsize
    SET TARGET PROFIT 8*pipsize
    

    Hi everyone,

    I posted this same code yesterday, and out of the blue (I don’t know why) now it does not operate everyday.

    It is a very simple breakout system with a reverse stop in case that the first trade does not work.

    The only problem is that only launches an average of 5-6 operations a month. I am playing with the INTRADAYBARINDEX command but nothing.

    Thanks a lot,

    Juan

    #39108 quote
    Nicolas
    Keymaster
    Master

    Hi Juan, I answered your question in the other thread here: https://www.prorealcode.com/topic/help-identifying-a-mistake-in-this-simple-code/

    Is this the same problem?

    #39112 quote
    Juan Salas
    Participant
    Master

    Hi Nicolas,

    Yes and yes. You gave me a solution yesterday but it didn´t seem to work completely. I have a tried to fixed myself but I don’t know why, the system doesn’t launch operations everyday.

    Ideally, it should launch one order (everyday after 08:00) once the price breaks the upper or lower limit of the channel formed with the range of the previous candlesticks (from 07:00 to 08:00), and in case of a negative outcome, it launches a reversal order after the stop loss is closed. That is it. No more trading until next day.

    I made it (with your instructions) to trade once a day and to launch a reversal order after the first stop loss, but somehow it only works 10 days a month. I have also removed the Maximum Range of 32 pips for the Channel, but that is not the problem.

    Thanks,

    Juan

    #39126 quote
    Nicolas
    Keymaster
    Master

    As I wrote yesterday in the other topic, you have to set your pending order at each bar .. but you disallow them after only 1 bar with your lines 36 and 44. So if the price doesn’t breach your upper or lower levels at the first bar, you’ll never get trade the rest of the day, because no new pending STOP orders are set!

    #39127 quote
    Nicolas
    Keymaster
    Master

    Please read once again the code I posted yesterday: https://www.prorealcode.com/topic/help-identifying-a-mistake-in-this-simple-code/#post-38995

    Just copy/paste.

    #39128 quote
    Juan Salas
    Participant
    Master

    Hi Nicolas,

    Sorry, I will pay more attention next time. You are completely right!!! It works!!! I was just right there.

    Thanks,

    Juan

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

Help debugging code. Not operating everyday. Why???


ProOrder: Automated Strategies & Backtesting

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

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

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