Do not trade a price range with losses from previous trades..

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #149830 quote
    Fran55Fran55
    Participant
    Veteran

    I need code, for example:
    The bot performs a losing trade on dax at 12920.
    The bot should never again trade in a range of 0.10% above and below 12920 … that is, it should never trade in the 12907-12933 range again.

    #149831 quote
    Fran55Fran55
    Participant
    Veteran

    Sorry managers for the previous post, problem with traductor again.

    #149832 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go (not tested):

    Once PerCent = 0.10      //10%
    Once LOrange = 0
    Once HIrange = 9999999
    If StrategyProfit >= StrategyProfit[1] Then
       LOrange = 0
       HIrange = 9999999
    Endif
    EntryConditions = 1
    EntryConditions = ((Not ((close >= LOrange) and (close <= HIrange))) And LOrange <> 0)
    If MyLongConditions and EntryConditions  Then
       Buy 1 contract at Market
       Set Stop pLoss 100
       Set Target pProfit 100
       LOrange = close - (close * PerCent)
       HIrange = close + (close * PerCent)
    Endif
    #149835 quote
    Fran55Fran55
    Participant
    Veteran

    Ok Roberto.

     

    But, with other losser operations.

     

    In backtest are 31 losser operations.

     

    I want no entry new operations on 31 differents ranges.

    #149837 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    The correct code is (still not tested):

    Once PerCent = 0.10      //10%
    Once LOrange = 0
    Once HIrange = 9999999
    If StrategyProfit >= StrategyProfit[1] Then
       LOrange = 0
       HIrange = 9999999
    Endif
    EntryConditions = 1
    If LOrange <> 0 Then
       If ((close >= LOrange) and (close <= HIrange)) Then
          EntryConditions = 0
       Endif
    Endif
    If MyLongConditions and EntryConditions Then
       Buy 1 contract at Market
       Set Stop pLoss 100
       Set Target pProfit 100
       LOrange = close - (close * PerCent)
       HIrange = close + (close * PerCent)
    Endif
    #149844 quote
    Fran55Fran55
    Participant
    Veteran

    This Code is correct to all bad positivos un backtest???

     

    Tomorrow see.

    #149845 quote
    Fran55Fran55
    Participant
    Veteran

    Sorry…

    Yo all bad trades of backtest???

    #149878 quote
    Fran55Fran55
    Participant
    Veteran

    This Codes no function, Roberto!

    #149896 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I found the bug, this works (tested on Dax, Daily TF):

    Once PerCent = 0.10      //10%
    Once LOrange = 0
    Once HIrange = 9999999
    EntryConditions = 1
    If LOrange <> 0 Then
       If ((close >= LOrange) and (close <= HIrange)) Then
          EntryConditions = 0
       Endif
    Endif
    MyLongConditions = (Not OnMarket) AND (close > average[10,0](close))
    If MyLongConditions and EntryConditions Then
       Buy 1 contract at Market
       Set Stop   pLoss   1000
       Set Target pProfit 1000
       LOrange = close - (close * PerCent)
       HIrange = close + (close * PerCent)
    Endif
    //graphonprice HIrange coloured(0,255,0,255)
    //graphonprice LOrange coloured(255,0,0,255)

    As you can see from the screenshot, the strategy stops trading, even if above average within the range, until it’s broken.

    x-3.jpg x-3.jpg
    #149930 quote
    Fran55Fran55
    Participant
    Veteran

    Ok Roberto, thanks!

     

    I see this night or tomorrow.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Do not trade a price range with losses from previous trades..


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Fran55 @fran55 Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by Fran55Fran55
5 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/08/2020
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...