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

Strategy Builder - Using a Buy/Sell indicator

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

  • bnoisette
    replied
    I fixed it

    Leave a comment:


  • bnoisette
    replied
    Originally posted by bnoisette View Post

    Thx for taking a look and pointing me in the right direction
    ok Sorry to inquire again but can you check to see if you can get it to take sell orders. I can get it to take buys but it is not taking doing sell orders. I actually changed the code to this (VolumeBasedBuySellSignals1.SellSignal[0] != 0) for the buy signal as well and all it does it take buy orders.

    Leave a comment:


  • bnoisette
    replied
    Here is what I have for the short section. On the longs it will still take trades without the print that is why I have it commented out here. The long is exactly the same except labeled "Buy"
    // Set 2
    if ((VolumeBasedBuySellSignals1.SellSignal[0] != 0)
    //&& (Close[0] <= Close[1])
    //&& ((BarsSinceExitExecution() > 3)
    //|| (BarsSinceExitExecution() == -1)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    //Print(@"VolumeBasedBuySellSignals1.SellSignal[0]:" + Convert.ToString(VolumeBasedBuySellSignals1.SellSi gnal[0]));
    }
    {
    EnterShort(1, @"ShortCTP");
    EnterShort(1, @"ShortCTR");​

    Leave a comment:


  • bnoisette
    replied
    Here is what I have for the short section. On the longs it will still take trades without the print that is why I have it commented out here. The long is exactly the same except labeled "Buy"
    // Set 2
    if ((VolumeBasedBuySellSignals1.SellSignal[0] != 0)
    //&& (Close[0] <= Close[1])
    //&& ((BarsSinceExitExecution() > 3)
    //|| (BarsSinceExitExecution() == -1)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    //Print(@"VolumeBasedBuySellSignals1.SellSignal[0]:" + Convert.ToString(VolumeBasedBuySellSignals1.SellSi gnal[0]));
    }
    {
    EnterShort(1, @"ShortCTP");
    EnterShort(1, @"ShortCTR");​

    Leave a comment:


  • bnoisette
    replied
    Originally posted by bnoisette View Post

    Thx for taking a look and pointing me in the right direction
    ok Sorry to inquire again but can you check to see if you can get it to take sell orders. I can get it to take buys but it is not taking doing sell orders. I actually changed the code to this (VolumeBasedBuySellSignals1.SellSignal[0] != 0) for the buy signal as well and all it does it take buy orders.

    Leave a comment:


  • bnoisette
    replied
    Originally posted by marco231 View Post
    I forgot to mention, if you run into little problems like this try painting the background for order execution and reviewing your order entry conditions and also open the data box to get an understanding of what the indicators are printing out (saves time from having to manually use the print function).
    Thx for taking a look and pointing me in the right direction

    Leave a comment:


  • marco231
    replied
    I forgot to mention, if you run into little problems like this try painting the background for order execution and reviewing your order entry conditions and also open the data box to get an understanding of what the indicators are printing out (saves time from having to manually use the print function).

    Leave a comment:


  • marco231
    replied
    Originally posted by bnoisette View Post
    Also the sell signal is committed out as I was trying to get the buy signal to work properly first.
    Thanks, I've managed to load your script and get it to take orders. The problem you had was that you are checking if the buy or sell signal =0 , when in actual fact it will never be 0 (it is always be NA or a number). The number it equals is the price the marker is created, see below image of highlighted green order circled in black, see the sell signal is NA in this instance. So the condition you need to check is (0 != VolumeBasedBuySellSignals1.BuySignal[1]).

    The other thing I noticed was this condition && (BarsSinceExitExecution(0, "", 0) > 3), I commented it out to get it to take a trade. You need to refine what this is as I'm not sure what this is checking. I had it active and it didn't take any trades over 5 days 23 hours of the market open.

    Anyway best of luck with your strategy, It looks like a great piece of work coming together !

    Click image for larger version

Name:	image.png
Views:	56
Size:	336.9 KB
ID:	1312036

    Leave a comment:


  • bnoisette
    replied
    Also the sell signal is committed out as I was trying to get the buy signal to work properly first.

    Leave a comment:


  • bnoisette
    replied
    Originally posted by marco231 View Post
    If you can share the source code of your script + where I can download the indicator then I can review your code for you and give better guidance on why the issue is occuring.
    Here you go. The indicator is there as well
    Attached Files

    Leave a comment:


  • marco231
    replied
    If you can share the source code of your script + where I can download the indicator then I can review your code for you and give better guidance on why the issue is occuring.

    Leave a comment:


  • marco231
    replied
    Originally posted by bnoisette View Post

    Yeah I have that. This is what I have tried and it is not working

    if ((0 == VolumeBasedBuySellSignals1.BuySignal[1])
    && (BarsSinceExitExecution(0, "", 0) > 3)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    Print(@"VolumeBasedBuySellSignals.BuySignal[0]:" + Convert.ToString(VolumeBasedBuySellSignals1.BuySig nal[0]));​
    is this a free indicator? the Volume Base Buy Sell Signals? It's hard to understand what is going on unless you share the code so that I can review and help you out. Otherwise we'll be doing a lot of back and forth here.

    Leave a comment:


  • bnoisette
    replied
    Originally posted by marco231 View Post

    I ended up reviewing my code and there was additional information , you need make sure your market position is flat as part of the condition you can do something like this , && (Position.MarketPosition == MarketPosition.Flat)) . So when you get a signal, it will check 1 are you in a trade (from a previous signal - if so do not open another trade), if you are flat and you get a signal then enter the trade.
    Yeah I have that. This is what I have tried and it is not working

    if ((0 == VolumeBasedBuySellSignals1.BuySignal[1])
    && (BarsSinceExitExecution(0, "", 0) > 3)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    Print(@"VolumeBasedBuySellSignals.BuySignal[0]:" + Convert.ToString(VolumeBasedBuySellSignals1.BuySig nal[0]));​

    Leave a comment:


  • marco231
    replied
    Originally posted by bnoisette View Post

    marco231 can you please share how you were able to get this to work? I use a similar indicator and I tried the print solution above and I get the same results.
    I ended up reviewing my code and there was additional information , you need make sure your market position is flat as part of the condition you can do something like this , && (Position.MarketPosition == MarketPosition.Flat)) . So when you get a signal, it will check 1 are you in a trade (from a previous signal - if so do not open another trade), if you are flat and you get a signal then enter the trade.

    Leave a comment:


  • marco231
    replied
    Make sure your logic is calculate on bar close, and try using other conditions. Like Close of previous candle must be below 50 EMA or SMA. or Only take shorts if price is under Vwap or take longs if above vwap.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Mr Bread, Today, 06:21 AM
1 response
11 views
0 likes
Last Post Mr Bread  
Started by tonydavisonline, Yesterday, 08:01 AM
1 response
26 views
0 likes
Last Post tonydavisonline  
Started by cbentrikin, Today, 05:30 AM
1 response
10 views
0 likes
Last Post cbentrikin  
Started by slimtrading, 04-05-2024, 04:23 PM
4 responses
192 views
0 likes
Last Post Sam2515
by Sam2515
 
Started by bltdavid, 03-04-2023, 05:05 PM
13 responses
1,335 views
0 likes
Last Post Gerry-N
by Gerry-N
 
Working...
X