Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trading a PIN bar logic not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trading a PIN bar logic not working

    Hello: I have this code that not working and only prints a log when I am not in Trade. What is missing so at least I get one trade.
    Logic to check the current bar open, close, high and low and see if high of the bar have formed Wick and place a trade long or short.
    Any syntax error causing it or something missing in the code. I build this using some Youtube videos but something is not right.
    Any help would be appreciated.
    Thanks,

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    Print("I am in NO trade.");


    if ((Close[0] == Low[0] && Open[0] > Close[0] && High[0] > Open[0] && CrossAbove(Close, MY_EMA, 1)))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"Buy");
    Print("I am in LONG trade.");

    }

    if ((Close[0] == High[0] && Open[0] < Close[0] && High[0] > Open[0] && CrossBelow(Close, MY_EMA, 1)))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), @"Sell");
    Print("I am in SHORT trade.");
    }



    // Set 6
    // if (BarsSinceExitExecution(0, "", 0) == 1)
    // {
    // Draw.Text(this, Convert.ToString(CurrentBars[0]), Convert.ToString(SystemPerformance.AllTrades.Trade sPerformance.Currency.CumProfit) + @" $", 0, (Low[0] + (25 * TickSize)) );
    // }

    }

    #2
    Hello mtamaku,

    The print "Print("I am in NO trade.");" should be appearing for every bar update.

    The entry order is only going to be submitted if the condition is evaluating as true.

    One line above the condition print the time of the bar and print each value being compared in the condition. Include labels for each value and comparison operator.

    We should be able to see in the output how each value is being compared.

    Below is a link to a forum post with videos that demonstrate how to use prints to understand behavior.


    Save the output to a text file and include this with your reply.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rhyminkevin, Today, 04:58 PM
    3 responses
    48 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X