Stratégie Dow M1 Midnight Candle

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #213913 quote
    Stanley20
    Participant
    New

    Hello, I have a code for a very simple strategy.

    Strategy :

    At the close of the midnight candle, I draw a line on the highest point and on the lowest point of it.

    Lorsqu’une bougie d’achat est franchie et se ferme au-dessus de la ligne du point le plus élevé, je prends un ordre d’achat.

    Lorsqu’une bougie de vente perce et se ferme sous la ligne du point bas, je passe un ordre de vente.

    À chaque position, le stop-loss est placé à 50 points et le take profit à 100 points.

    Il est possible que le graphique ait un ordre d’achat et de vente en même temps.

    Cette stratégie est applicable sur l’unité de temps de 1 minute.

    Je recommencerais le code chaque jour en entrant les valeurs de la bougie la plus haute et la plus basse (par défaut 1440 sur ce code).

    When a buy candle is crossed and closes above the high point line, I place a buy order.

    When a sell candle breaks through and closes below the low line, I place a sell order.

    At each position, the stop-loss is placed at 50 points and the take profit at 100 points.

    It is possible that the chart has a buy and sell order at the same time.

    This strategy is applicable on 1 minute timeframe.

    I would start the code over each day by entering the values of the highest and lowest candle (default 1440 on this code).

     

    // Déclaration des variables
    vars: MaxHigh(0), MinLow(0), BuySignal(False), SellSignal(False), StopLoss(0), TakeProfit(0);
    
    // Récupération de la valeur du point
    value1point = Point;
    
    // Si on est sur la bougie de minuit, on trace le trait horizontal
    if Time = 0000 then begin
        // Calcul du point le plus haut et du point le plus bas de la bougie
        MaxHigh = Highest(High, 1440);
        MinLow = Lowest(Low, 1440);
        
        // Dessin des lignes horizontales
        DrawLine("MaxHigh", 0, MaxHigh, 1440, MaxHigh, Blue);
        DrawLine("MinLow", 0, MinLow, 1440, MinLow, Red);
    end;
    
    // Si une bougie acheteuse franchit la ligne horizontale du point le plus haut
    if Close crosses above MaxHigh and not SellSignal then begin
        // On prend une position à l'achat
        BuySignal = True;
        SellSignal = False;
        StopLoss = Close - 50 * value1point;
        TakeProfit = Close + 100 * value1point;
        Buy next bar at Close stop;
    end;
    
    // Si une bougie vendeuse franchit la ligne horizontale du point le plus bas
    if Close crosses below MinLow and not BuySignal then begin
        // On prend une position à la vente
        SellSignal = True;
        BuySignal = False;
        StopLoss = Close + 50 * value1point;
        TakeProfit = Close - 100 * value1point;
        Sell short next bar at Close stop;
    end;
    
    // Gestion des positions ouvertes
    if MarketPosition = 1 then begin // Position à l'achat
        SetStopLoss(StopLoss);
        SetProfitTarget(TakeProfit);
    end
    else if MarketPosition = -1 then begin // Position à la vente
        SetStopLoss(StopLoss);
        SetProfitTarget(TakeProfit);
    end;

    Comme vous pouvez le voir, j’ai des messages d’erreur et je ne trouve pas d’où ça vient …

    Avez-vous une idée du problème? Merci

     

    As you can see, I have error messages and I can’t find where it comes from…

    Do you have an idea of ​​the problem? Thanks

    erreur-code-trading.png erreur-code-trading.png
    #213915 quote
    BaptDem
    Participant
    New

    Hello, I have a code for a very simple strategy.

    Strategy :

    At the close of the midnight candle, I draw a line on the highest point and on the lowest point of it.

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>When a buy candle is crossed and closes above the high point line, I place a buy order.</span></span> </span>

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>When a sell candle breaks through and closes below the low line, I place a sell order.</span></span> </span>

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>At each position, the stop-loss is placed at 50 points and the take profit at 100 points.</span></span> </span>

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>It is possible that the chart has a buy and sell order at the same time.</span></span> </span>

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>This strategy is applicable on the time unit of 1 minute.</span></span> </span>

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>I would start the code over each day by entering the values of the highest and lowest candle (default 1440 on this code).</span></span></span>

     

    <span class=”HwtZe” lang=”en”><span class=”jCAhz ChMk0b”><span class=”ryNqvb”>As you can see, I have error messages and I can’t find where it comes from…</span></span> <span class=”jCAhz ChMk0b”><span class=”ryNqvb”>Do you have an idea of ​​the problem?</span></span> <span class=”jCAhz ChMk0b”><span class=”ryNqvb”>THANKS</span></span></span> 🙂

    #213916 quote
    GraHal
    Participant
    Master

    I got your code to run by correcting many syntax errors etc.

    If you want to see my changes then copy and paste your code and my code into this …

    https://www.diffchecker.com/

    DEFPARAM CUMULATEORDERS = False
    // Déclaration des variables
    //vars: MaxHigh(0), MinLow(0), BuySignal(False), SellSignal(False), StopLoss(0), TakeProfit(0);
     
    // Récupération de la valeur du point
    value1point = pipsize //Pont //;
     
    // Si on est sur la bougie de minuit, on trace le trait horizontal
    if Time = 000000 then //begin
    // Calcul du point le plus haut et du point le plus bas de la bougie
    MaxHigh = Highest[1440](High) //, 1440);
    MinLow = Lowest[1440](Low) //, 1440);
        
    // Dessin des lignes horizontales
    //DrawLine("MaxHigh", 0, MaxHigh, 1440, MaxHigh, Blue);
    //drawLine("MinLow", 0, MinLow, 1440, MinLow, Red);
    endIF //;
     
    // Si une bougie acheteuse franchit la ligne horizontale du point le plus haut
    if Close crosses OVER MaxHigh and not SellSignal then // begin
    // On prend une position à l'achat
    BuySignal = 1 //True //;
    SellSignal = 0 //False;
    StopLoss = Close - 50 * value1point //;
    TakeProfit = Close + 100 * value1point //;
    Buy at Close stop //;
    endIF //;
     
    // Si une bougie vendeuse franchit la ligne horizontale du point le plus bas
    if Close crosses UNDER MinLow and not BuySignal then //begin
    // On prend une position à la vente
    SellSignal = 1 //True //;
    BuySignal = 0 //False;
    StopLoss = Close + 50 * value1point //;
    TakeProfit = Close - 100 * value1point //;
    Sellshort at Close stop //;
    endIF //;
     
    // Gestion des positions ouvertes
    if CountofPosition = 1 then //begin // Position à l'achat
    Set Stop Loss(StopLoss) //;
    Set Target Profit (TakeProfit)//;
    endIF
    If CountofPosition = -1 then //begin // Position à la vente
    Set Stop Loss(StopLoss) //;
    Set Target Profit(TakeProfit) //;
    endif //;
    
    #213919 quote
    GraHal
    Participant
    Master

    I may have interpreted a few things incorrectly / not as you want.

    I just whipped through the code to see if I could get it to run with no errors.

    Hope it helps you to move forward.

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

Stratégie Dow M1 Midnight Candle


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Stanley20 @stanley20 Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by GraHal
2 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/30/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...