50 points system, no indikator needed

Forums ProRealTime English forum ProOrder support 50 points system, no indikator needed

  • This topic has 10 replies, 4 voices, and was last updated 6 days ago by avatarJS.
Viewing 11 posts - 1 through 11 (of 11 total)
  • #246784

    Hello dear people, maybe someone can help me, I am not a light in programming, but here is an approach that differs from the usual indicator-driven approach.  In some of the forums I frequent, the following approach is used for indices, especially the Dax40.

    the system
    When the market opens at 08.00 or even 09.00, any trend direction is assumed, purely arbitrary, let’s say long.
    For the first trade of the day, the SL and TP are set at 50 points.
    If the TP is reached in the 1st trade, the system will not execute any further trades on this day.
    If the SL is reached in the 1st trade, a 2nd trade in the opposite direction (short) is started immediately. SL 50 points, TP 100 points.
    If the TP is reached in the 2nd trade, the system will not execute any further trades on that day.
    If the SL is reached in the 2nd trade, a 3rd and last trade started on this day, again in the opposite direction, i.e. in this case again long. SL 50 points, TP 150 points.
    Regardless of whether the SL or TP is reached in the 3rd trade, the system is terminated on this day.

    The same game is then played the next day with the change that the arbitrary trade direction is the opposite trade direction of the previous day. The 1st trade would therefore be short. The 2nd trade would be long, the 3rd trade would be short again.

    On the day after next we start again in the opposite direction of the previous day, with long, on the 4th day then with short, on the 5th day with long and so on.

    Trading only takes place Monday to Friday without the addition of Sunday. The overnight risk is initially neglected. Cumulateorders = false. The system only starts once a day and is limited to a maximum of 3 trades and thus 150 points loss.

    Can this be programmed with ProRealCode? The main difficulty I see is the exact change after reaching the respective SL.

    Here again the SL and TP
    sl1 = 50
    tp1 = 50

    sl2 = 50
    tp2 = 100

    sl3 = 50
    tp3 = 150

     

    When asked why points, I say we can also use percentages. I hold 50 points in the Dax40 at 20,000 points in dax a few days ago, we would be at 0.25%. However, people there have got hooked on the 50 points.

    #246800

    Hi! Here you have an example

    1 user thanked author for this post.
    #246824

    Hello Ivan. Thank you! The help/translation came with blue light, “nee-naw, woop-woop”. Thank you very much.

    I’ll take a look at it over the next 1.2 days to understand it. I’ll be back.

    #246971

    Hello Ivan.

    Thanks again for programming the system. I was able to take a look at it today and your program already does a lot of things right!
    For example, if the 1st trade ends with a loss, the 2nd trade is started in the opposite direction, it works perfectly!
    Also correct is: SL always 50 points and TP staggered TP1 50 points, TP2 points, TP 3 points, works, great!

    But now to the problem. See screenshot 1
    Chart Dax40 M1,  Day 10.04.2025 start time 09.00 am
    The 1st trade goes into the TP. Fits, works!
    But (!!) then the system opens further trades on 10.04.! That’s not supposed to happen! It’s only about 50 points. If a profit of 50 points is made on a day (maybe with the 1st trade), then no more trades are made on that day!

    If 1.trade goes into winnings, then no more trades on that day. You have your 50 points
    If 1st trade goes into loss, then and only then, will a 2nd trade be started on that day, in the opposite direction of course. The 2nd trade has TP 100, of course.

    If 2nd trade goes into profit, that’s it for the day, then no more trades on that day! You have your 50 points (1×50 loss and 1×100 profit).
    If 2nd trade goes into loss, then and only then, is a 3rd trade started. Again in the opposite direction, of course. The 2nd trade has TP 150, of course.

    If 3rd trade TP is in profit or in loss, it is no longer traded on that day. No (!) 4th trade is started, never! Either you have 3x 50 points loss or summary 1x 50 profit .

     

    But and now here is the problem. On 10.04. he starts more than 3 trades and also or although already the 1st trade ends with 50 points in profit. See screenshot attached.

     

    Can you change that the system
    a. stops after 50 points profit on a day (will reached with 1 oder 2 trades) or
    b. in case 2 consecutive losses on the same day the system starts only a 3rd, a last trade on that day.

     

    On the next day the system should then start from the beginning with the 1st trade, of course.

    Can you do that?

    lg and gl

    #249344

    I would like to ask for your help once again. The last time the request was not completed successfully. But: I am very grateful for what has already been done. Here, what people do is free of charge and that’s why, once again, a big thank you.

    I have now had the text translated into mql5. Please see below. The text is not mine, the idea is not mine, I am only the messenger. The idea comes from @tenerife and @marjok. The translation into mql5 comes frome @SifaMwenda (sifafxteam). Special thanks to them too, especially to them.

     

    Now the code mql5…….
    If someone can translate it and prt allows it, please don’t forget to point to the people behind the code.

    after that you are welcome to add it to your library

    this is the oringinal code of the original trading , no improvement

     

    //+——————————————————————+
    //| Daily Direction Switch EA.mq5 |
    //| sifafx |
    //| |
    //+——————————————————————+
    #property copyright “Sifafx Team”
    #property link “https://chat.whatsapp.com/G0PqvlJ2bW40PSXuBQpdsb”
    #property version “1.02”
    #property strict

    #include <Trade\Trade.mqh>
    #include <Trade\PositionInfo.mqh>
    #include <Trade\DealInfo.mqh>

    //— Input parameters
    input group “=== Handelseinstellungen ===”
    input double LotSize = 0.1; // Lot-Größe
    input bool UsePercentSLTP = true; // Prozent für SL/TP verwenden (false = Punkte)
    input int StartHour = 9; // Startstunde für ersten Trade
    input int StartMinute = 0; // Startminute für ersten Trade
    input int CloseHour = 21; // Alle Positionen schließen um diese Uhrzeit
    input int CloseMinute = 0; // Schließminute
    input string TradeComment = “TagesRichtung”; // Trade-Kommentar

    input group “=== Richtungssteuerung ===”
    input bool ManualFirstDirection = false; // Erste Richtung manuell setzen
    input bool FirstTradeDirection = true; // true=Long, false=Short (nur wenn manuell)

    input group “=== Risikomanagement ===”
    input double SL_Percent_Trade1 = 0.25; // SL in % für Trade 1
    input double TP_Percent_Trade1 = 0.25; // TP in % für Trade 1
    input double SL_Percent_Trade2 = 0.25; // SL in % für Trade 2
    input double TP_Percent_Trade2 = 0.5; // TP in % für Trade 2
    input double SL_Percent_Trade3 = 0.25; // SL in % für Trade 3
    input double TP_Percent_Trade3 = 0.75; // TP in % für Trade 3

    input int SL_Points_Trade1 = 50; // SL in Punkten für Trade 1
    input int TP_Points_Trade1 = 50; // TP in Punkten für Trade 1
    input int SL_Points_Trade2 = 50; // SL in Punkten für Trade 2
    input int TP_Points_Trade2 = 100; // TP in Punkten für Trade 2
    input int SL_Points_Trade3 = 50; // SL in Punkten für Trade 3
    input int TP_Points_Trade3 = 150; // TP in Punkten für Trade 3

    //— Global variables
    CTrade trade;
    CPositionInfo positionInfo;
    CDealInfo dealInfo;

    datetime LastTradeDate = 0;
    int DailyTradeCount = 0;
    bool FirstTradeIsLong = true; // Direction for first trade of the day
    bool TradingEnabled = true;
    bool DayFinished = false;
    int Magic = 12345;
    ulong LastPositionTicket = 0;
    bool WaitingForNextTrade = false;
    datetime LastPositionCloseTime = 0;

    //+——————————————————————+
    //| Expert initialization function |
    //+——————————————————————+
    int OnInit()
    {
    Print(“Täglich wechselnder EA initialisiert – Version 1.02”);

    // Trade-Einstellungen konfigurieren
    trade.SetExpertMagicNumber(Magic);
    trade.SetDeviationInPoints(10);
    trade.SetTypeFilling(ORDER_FILLING_IOC);

    // Erste Trade-Richtung bestimmen
    if(ManualFirstDirection)
    {
    // Manuelle Richtungssteuerung verwenden
    FirstTradeIsLong = FirstTradeDirection;
    Print(“=== MANUELLE RICHTUNGSSTEUERUNG AKTIV ===”);
    Print(“Erste Trade-Richtung manuell gesetzt auf: “, FirstTradeIsLong ? “LONG” : “SHORT”);
    }
    else
    {
    // Automatische Richtungsbestimmung basierend auf Tagesnummer
    MqlDateTime dt;
    TimeToStruct(TimeCurrent(), dt);
    FirstTradeIsLong = (dt.day % 2 == 1);
    Print(“=== AUTOMATISCHE RICHTUNGSSTEUERUNG AKTIV ===”);
    Print(“Erste Trade-Richtung automatisch bestimmt: “, FirstTradeIsLong ? “LONG” : “SHORT”);
    Print(“Basierend auf Tagesnummer: “, dt.day);
    }

    Print(“EA bereit für Handel ab “, StartHour, “:”, StringFormat(“%02d”, StartMinute), ” Uhr”);
    Print(“Zeitstopp aktiviert um “, CloseHour, “:”, StringFormat(“%02d”, CloseMinute), ” Uhr”);

    return(INIT_SUCCEEDED);
    }

    //+——————————————————————+
    //| Expert deinitialization function |
    //+——————————————————————+
    void OnDeinit(const int reason)
    {
    Print(“Täglich wechselnder EA deinitialisiert. Grund: “, reason);
    }

    //+——————————————————————+
    //| Expert tick function |
    //+——————————————————————+
    void OnTick()
    {
    // Prüfung auf neuen Tag
    CheckNewDay();

    // Zeitstopp prüfen
    CheckTimeStop();

    // Prüfen ob Tag beendet oder Handel deaktiviert
    if(DayFinished || !TradingEnabled) return;

    // Prüfen ob Handelszeit erreicht ist
    if(!ShouldStartTrading()) return;

    // Prüfen ob maximale Tagesanzahl erreicht
    if(DailyTradeCount >= 3)
    {
    DayFinished = true;
    return;
    }

    // Aktuelle Positionen zählen
    int currentPositions = CountOurPositions();

    // Ersten Trade eröffnen wenn keine Position und kein Trade heute
    if(currentPositions == 0 && DailyTradeCount == 0)
    {
    OpenFirstTrade();
    }

    // Nächsten Trade eröffnen wenn auf Fortsetzung gewartet wird
    if(currentPositions == 0 && WaitingForNextTrade && DailyTradeCount < 3)
    {
    // Kurze Wartezeit nach Positionsschließung um sofortige Wiedereröffnung zu vermeiden
    if(TimeCurrent() – LastPositionCloseTime > 1)
    {
    OpenNextTrade();
    WaitingForNextTrade = false;
    }
    }
    }

    //+——————————————————————+
    //| Prüfung auf neuen Tag |
    //+——————————————————————+
    void CheckNewDay()
    {
    MqlDateTime current_time;
    TimeToStruct(TimeCurrent(), current_time);

    datetime todayStart = StringToTime(TimeToString(TimeCurrent(), TIME_DATE));
    datetime lastTradeDateStart = StringToTime(TimeToString(LastTradeDate, TIME_DATE));

    // Wenn es ein neuer Tag ist
    if(todayStart != lastTradeDateStart)
    {
    // Tägliche Zähler zurücksetzen
    DailyTradeCount = 0;
    TradingEnabled = true;
    DayFinished = false;
    WaitingForNextTrade = false;
    LastPositionTicket = 0;

    // Richtung für neuen Tag wechseln (nur bei automatischer Steuerung)
    if(LastTradeDate != 0) // Nicht am ersten Tag wechseln
    {
    if(!ManualFirstDirection) // Nur bei automatischer Steuerung
    {
    FirstTradeIsLong = !FirstTradeIsLong;
    Print(“=== AUTOMATISCHER RICHTUNGSWECHSEL ===”);
    }
    else
    {
    Print(“=== MANUELLE RICHTUNG BEIBEHALTEN ===”);
    }
    }

    LastTradeDate = TimeCurrent();

    Print(“=== NEUER TAG GESTARTET ===”);
    Print(“Erste Trade-Richtung: “, FirstTradeIsLong ? “LONG” : “SHORT”);
    Print(“Täglicher Trade-Zähler auf 0 zurückgesetzt”);
    Print(“Richtungssteuerung: “, ManualFirstDirection ? “MANUELL” : “AUTOMATISCH”);
    }
    }

    //+——————————————————————+
    //| Prüfung ob Handel gestartet werden soll |
    //+——————————————————————+
    bool ShouldStartTrading()
    {
    if(!TradingEnabled || DayFinished) return false;

    MqlDateTime dt;
    TimeToStruct(TimeCurrent(), dt);

    // Prüfen ob aktuelle Zeit nach Startzeit liegt
    int currentMinutes = dt.hour * 60 + dt.min;
    int startMinutes = StartHour * 60 + StartMinute;

    return (currentMinutes >= startMinutes);
    }

    //+——————————————————————+
    //| Zeitstopp prüfen und Positionen schließen |
    //+——————————————————————+
    void CheckTimeStop()
    {
    MqlDateTime dt;
    TimeToStruct(TimeCurrent(), dt);

    int currentMinutes = dt.hour * 60 + dt.min;
    int closeMinutes = CloseHour * 60 + CloseMinute;

    if(currentMinutes >= closeMinutes)
    {
    if(CountOurPositions() > 0)
    {
    CloseAllOurPositions();
    Print(“Alle Positionen wegen Zeitstopp um “, CloseHour, “:”, CloseMinute, ” geschlossen”);
    }

    DayFinished = true; // Tag als beendet markieren
    }
    }

    //+——————————————————————+
    //| Ersten Trade des Tages eröffnen |
    //+——————————————————————+
    void OpenFirstTrade()
    {
    ENUM_ORDER_TYPE orderType = FirstTradeIsLong ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;

    double sl = 0, tp = 0;
    CalculateSLTP(1, orderType, sl, tp);

    if(OpenPosition(orderType, sl, tp))
    {
    DailyTradeCount = 1;
    Print(“=== TRADE 1 ERÖFFNET ===”);
    Print(“Richtung: “, EnumToString(orderType));
    Print(“SL: “, sl, ” TP: “, tp);
    Print(“Richtungssteuerung: “, ManualFirstDirection ? “MANUELL” : “AUTOMATISCH”);
    }
    }

    //+——————————————————————+
    //| Nächsten Trade eröffnen (nach SL-Treffer) |
    //+——————————————————————+
    void OpenNextTrade()
    {
    // Gegenrichtung vom letzten Trade bestimmen
    ENUM_ORDER_TYPE nextOrderType;

    // Richtungsmuster für aktuelle Trade-Nummer bestimmen
    if(DailyTradeCount == 1)
    {
    // Trade 2: Gegenrichtung von Trade 1
    nextOrderType = FirstTradeIsLong ? ORDER_TYPE_SELL : ORDER_TYPE_BUY;
    }
    else if(DailyTradeCount == 2)
    {
    // Trade 3: Gleiche Richtung wie Trade 1
    nextOrderType = FirstTradeIsLong ? ORDER_TYPE_BUY : ORDER_TYPE_SELL;
    }
    else
    {
    return; // Sollte nicht auftreten
    }

    double sl = 0, tp = 0;
    CalculateSLTP(DailyTradeCount + 1, nextOrderType, sl, tp);

    if(OpenPosition(nextOrderType, sl, tp))
    {
    DailyTradeCount++;
    Print(“=== TRADE “, DailyTradeCount, ” ERÖFFNET ===”);
    Print(“Richtung: “, EnumToString(nextOrderType));
    Print(“SL: “, sl, ” TP: “, tp);
    Print(“Grund: Stop Loss von Trade “, DailyTradeCount-1, ” erreicht”);
    }
    }

    //+——————————————————————+
    //| SL und TP basierend auf Trade-Nummer berechnen |
    //+——————————————————————+
    void CalculateSLTP(int tradeNumber, ENUM_ORDER_TYPE orderType, double &sl, double &tp)
    {
    double currentPrice = (orderType == ORDER_TYPE_BUY) ?
    SymbolInfoDouble(_Symbol, SYMBOL_ASK) :
    SymbolInfoDouble(_Symbol, SYMBOL_BID);

    double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
    int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);

    if(UsePercentSLTP)
    {
    // Prozentuale Berechnung
    double slPercent, tpPercent;

    switch(tradeNumber)
    {
    case 1:
    slPercent = SL_Percent_Trade1 / 100.0;
    tpPercent = TP_Percent_Trade1 / 100.0;
    break;
    case 2:
    slPercent = SL_Percent_Trade2 / 100.0;
    tpPercent = TP_Percent_Trade2 / 100.0;
    break;
    case 3:
    slPercent = SL_Percent_Trade3 / 100.0;
    tpPercent = TP_Percent_Trade3 / 100.0;
    break;
    default:
    slPercent = SL_Percent_Trade1 / 100.0;
    tpPercent = TP_Percent_Trade1 / 100.0;
    break;
    }

    if(orderType == ORDER_TYPE_BUY)
    {
    sl = NormalizeDouble(currentPrice * (1 – slPercent), digits);
    tp = NormalizeDouble(currentPrice * (1 + tpPercent), digits);
    }
    else
    {
    sl = NormalizeDouble(currentPrice * (1 + slPercent), digits);
    tp = NormalizeDouble(currentPrice * (1 – tpPercent), digits);
    }
    }
    else
    {
    // Punkte-basierte Berechnung
    int slPoints, tpPoints;

    switch(tradeNumber)
    {
    case 1:
    slPoints = SL_Points_Trade1;
    tpPoints = TP_Points_Trade1;
    break;
    case 2:
    slPoints = SL_Points_Trade2;
    tpPoints = TP_Points_Trade2;
    break;
    case 3:
    slPoints = SL_Points_Trade3;
    tpPoints = TP_Points_Trade3;
    break;
    default:
    slPoints = SL_Points_Trade1;
    tpPoints = TP_Points_Trade1;
    break;
    }

    if(orderType == ORDER_TYPE_BUY)
    {
    sl = NormalizeDouble(currentPrice – slPoints * point, digits);
    tp = NormalizeDouble(currentPrice + tpPoints * point, digits);
    }
    else
    {
    sl = NormalizeDouble(currentPrice + slPoints * point, digits);
    tp = NormalizeDouble(currentPrice – tpPoints * point, digits);
    }
    }
    }

    //+——————————————————————+
    //| Position eröffnen |
    //+——————————————————————+
    bool OpenPosition(ENUM_ORDER_TYPE orderType, double sl, double tp)
    {
    double price = (orderType == ORDER_TYPE_BUY) ?
    SymbolInfoDouble(_Symbol, SYMBOL_ASK) :
    SymbolInfoDouble(_Symbol, SYMBOL_BID);

    bool result = false;

    if(orderType == ORDER_TYPE_BUY)
    {
    result = trade.Buy(LotSize, _Symbol, price, sl, tp, TradeComment);
    }
    else
    {
    result = trade.Sell(LotSize, _Symbol, price, sl, tp, TradeComment);
    }

    if(result)
    {
    LastPositionTicket = trade.ResultOrder();
    Print(“Position erfolgreich eröffnet. Ticket: “, LastPositionTicket);
    }
    else
    {
    Print(“Position konnte nicht eröffnet werden. Fehler: “, trade.ResultRetcode(), ” – “, trade.ResultRetcodeDescription());
    }

    return result;
    }

    //+——————————————————————+
    //| Unsere Positionen zählen |
    //+——————————————————————+
    int CountOurPositions()
    {
    int count = 0;
    for(int i = PositionsTotal() – 1; i >= 0; i–)
    {
    if(positionInfo.SelectByIndex(i))
    {
    if(positionInfo.Symbol() == _Symbol && positionInfo.Magic() == Magic)
    {
    count++;
    }
    }
    }
    return count;
    }

    //+——————————————————————+
    //| Alle unsere Positionen schließen |
    //+——————————————————————+
    void CloseAllOurPositions()
    {
    for(int i = PositionsTotal() – 1; i >= 0; i–)
    {
    if(positionInfo.SelectByIndex(i))
    {
    if(positionInfo.Symbol() == _Symbol && positionInfo.Magic() == Magic)
    {
    trade.PositionClose(positionInfo.Ticket());
    }
    }
    }
    }

    //+——————————————————————+
    //| Trade-Transaction-Handler |
    //+——————————————————————+
    void OnTradeTransaction(const MqlTradeTransaction& trans,
    const MqlTradeRequest& request,
    const MqlTradeResult& result)
    {
    // Nur Deal-Transaktionen verarbeiten
    if(trans.type != TRADE_TRANSACTION_DEAL_ADD) return;

    // Deal auswählen
    if(!HistoryDealSelect(trans.deal))
    return;

    // Deal-Informationen abrufen
    string symbol = HistoryDealGetString(trans.deal, DEAL_SYMBOL);
    long magic = HistoryDealGetInteger(trans.deal, DEAL_MAGIC);
    ENUM_DEAL_ENTRY entry = (ENUM_DEAL_ENTRY)HistoryDealGetInteger(trans.deal, DEAL_ENTRY);
    ENUM_DEAL_REASON reason = (ENUM_DEAL_REASON)HistoryDealGetInteger(trans.deal, DEAL_REASON);

    // Prüfen ob es unser Deal ist und Position geschlossen wurde
    if(symbol != _Symbol || magic != Magic || entry != DEAL_ENTRY_OUT)
    return;

    LastPositionCloseTime = TimeCurrent();

    Print(“=== POSITION GESCHLOSSEN ===”);
    Print(“Grund: “, EnumToString(reason));
    Print(“Trade-Nummer war: “, DailyTradeCount);

    // Positionsschließung behandeln
    if(reason == DEAL_REASON_TP)
    {
    Print(“Take Profit erreicht! Keine weiteren Trades heute.”);
    Print(“=== TAG ERFOLGREICH BEENDET ===”);
    DayFinished = true;
    }
    else if(reason == DEAL_REASON_SL)
    {
    Print(“Stop Loss erreicht!”);
    if(DailyTradeCount < 3)
    {
    Print(“Werde nächsten Trade in Gegenrichtung eröffnen…”);
    WaitingForNextTrade = true;
    }
    else
    {
    Print(“Maximale Trades erreicht. Keine weiteren Trades heute.”);
    Print(“=== TAG NACH 3 VERLUSTEN BEENDET ===”);
    DayFinished = true;
    }
    }
    else
    {
    // Manueller Schluss oder andere Gründe
    Print(“Position manuell geschlossen oder durch Zeitstopp.”);
    if(reason != DEAL_REASON_EXPERT) // Wenn nicht durch unseren Zeitstopp geschlossen
    {
    DayFinished = true; // Handel für den Tag stoppen
    }
    }
    }

     

     

     

     

     

     

    #249349

    it runs in de40 08:00:00 und us100 15:30:00

    #249494

    Da will man etwas beitragen und die Hilfe dafür kommt nicht. Nicht mal eine Antwort kommt. Man weiß nach 3 Tagen nicht mal, ob sich dass in prt programmieren lässt oder jemand daran denkt zu helfen ……

    You want to contribute something, but you don’t get any help. Not even a response. After three days, you don’t even know if it can be programmed in PRT or if someone will even think about helping…

    #249498

    @f1_maik

    • Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
      .
    • It may happen that people have plenty of work to do or maybe rthey don’t feel well, etc… and need more time to address some questions. It seems you have been answered many times in the last years, so I think you can’t complain you haven’t been helped!

    Please be a little more patient. Thanks 🙂

     

    1 user thanked author for this post.
    #249519

    I’ll leave it at that and consider my contribution done. I’ll use the mql5 coding, that’s what it’s there for. Best.

    #249520

    it runs at mt5 11586186 since june this year in test there you na see it .. byebye holy prorealtime-community I am deeply disappointed nice and pls take a look on the wild side little joe .. doo, doo-doo, doo-doo, doo-doo-doo

    #249522
    JS

    FYI, as you know, Iván handles all conversions on the platform. He does an incredible job and is probably the only one on the forum who can do this so quickly and accurately…
    Iván is likely on vacation during this holiday period, so conversions are temporarily on hold — all conversions, not just yours…

Viewing 11 posts - 1 through 11 (of 11 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login