Buy on retest on a certain candle

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #236823 quote
    Jimmy Olsson
    Participant
    New

    Hi!

    Im struggle with coding .

    I whant the code to buy after  one specific candle.

    example , the retest of the 09:15 candles low.

    How do i code that ? seams that AI dossent help either haha!

    #236826 quote
    JS
    Participant
    Veteran

    Hi Jimmy,

    Do you mean something like this…?

     

    DefParam CumulateOrders=False
    
    If OpenTime=091500 then
    LowCandle=Low
    EndIf
    
    If Time>091500 then
    If Close<=LowCandle then
    Buy 1 contract at Market
    EndIf
    EndIf
    
    #236838 quote
    Jimmy Olsson
    Participant
    New

    I have something like this. But it dossent take a single trade.

    DefParam CumulateOrders=False

    // Variables to store the low and high price of the first candle
    If OpenTime = 091500 then
    LowCandle = Low
    HighCandle = High
    CandleRange = HighCandle – LowCandle // Calculate the range of the 09:15 candle
    EndIf

    // Execute buy order if the current price touches or goes below the LowCandle
    // AND the time is between 09:15 and 12:00
    If Time >= 091500 and Time <= 120000 then
    If Low <= LowCandle then
    // Place buy order
    Buy 1 contract at Market

    // Assuming we’re using a platform that allows capturing the last trade price
    LastTradePrice = Close // or the appropriate function to get the entry price

    // Set stop loss at the distance of the candle range below the entry price
    SET STOP LOSS (LastTradePrice – CandleRange) // Correctly set the stop loss

    // Set take profit at the high of the 09:15 candle
    SET TARGET PROFIT (HighCandle) // Correctly set the take profit
    EndIf
    EndIf

    #236839 quote
    JS
    Participant
    Veteran
    If OpenTime = 091500 then
    LowCandle = Low
    HighCandle = High
    CandleRange = (HighCandle - LowCandle)
    EndIf
    
    If Time >= 091500 and Time <= 120000 then
    If Low <= LowCandle then
    Buy 1 contract at Market
    EndIf
    
    Set Stop Loss CandleRange
    Set Target Price HighCandle
    EndIf
    Scherm­afbeelding-2024-08-29-om-13.45.15.jpg Scherm­afbeelding-2024-08-29-om-13.45.15.jpg
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Buy on retest on a certain candle


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by JS
1 year, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/29/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...