Sma / profit curve condition

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #232493 quote
    winnie37
    Participant
    Veteran

    Hello,
    I’ve added a SMA to the profit curve of a system (whichever it is).
    I’d like to test adding a condition for buying or selling.
    A trade should only be triggered if the condition is met.
    For the trade to be triggered, the profit curve must be greater than its moving average.
    Is this possible? Any idea on how to translate this into code?

    Capture-decran-2024-05-08-163641.png Capture-decran-2024-05-08-163641.png
    #232498 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ProfitMA = average[20,0](StrategyProfit)
    Above    = ProfitMA >= StrategyProfit
    Below    = ProfitMA < StrategyProfit
    IF Not OnMarket THEN
       IF Below THEN
          BUY 1 CONTRACT AT MARKET
       ELSIF Above THEN
          SELLSHORT 1 CONTRACT AT MARKET
       ENDIF
       SET STOP   pLOSS   50
       SET TARGET pPROFIT 100
    ENDIF
    //
    graph StrategyProfit coloured("Blue")
    graph ProfitMA       coloured("Red")

    add the variables Above or Below to your entry conditions.

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

Sma / profit curve condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
winnie37 @winnie37 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
1 year, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/08/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...