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!
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
NinjaTrader
CALL indicator from strategy to pullscreenshots
Collapse
X
-
CALL indicator from strategy to pullscreenshots
i updated the sample indicator to take screenshots every 4 hours. its event driven. i run my strategies on my chart. how can i call this indicator from my strategy to take screenshots at open and close of trades?
Tags: None
-
Hello junkone,
Thank you for the post.
Normally you would need to make the private void into public void however because this is being Hosted the ChartControl should be null when used from a strategy. This would be best moved into the strategy where you can use the ChartControl from the strategy where it is applied. An alternate could be to make an overload for the method which takes ChartControl and pass that from your strategy to the method so it can be used/not null. It may be just as easy to include this in the strategy and surround it in a region to hide it once complete.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Hello junkone,
Before we work toward detecting if it is being hosted, can you clarify, do you also want the timed images from the timer in the indicator or are you trying to call the screenshot code from the strategy to take a screenshot at specific times?
The indicator is programmed to start the timer when used, so it may need modified more depending on what the overall goal is. The code your strategy needs to take the image is in the indicator, however to call it you will also start the timer and you are not doing any error checking in that area. If that is not the goal to also start the timer, it would be easiest to copy the screenshot code so you don't have to make the indicator more complex. you can of course make the indicator more complex, but that will again depend on the goal with the timer.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
-
good point. i want to have the timed screenshots in place. i also want to able to trigger screenshots from the strategy. this will allow me to publish the screenshots from strategy to my blog with automated stats printed on it.
the only reason why i was thinking of keeping code in indicator was to keep it in one place. i want to be able to call the screenshots code from multiple strategies.
Comment
-
Hello junkone,
In that case you would likely need to modify a few parts of the indicator. You can use AddChartIndicator here to add the indicator which will get the buttons and start the timer. Here are some items I can note about what might need to change:- Add checks in your timers code to make sure that does not have errors for cases if ChartControl is null.
- Picking a better way to start the timer, such as a button would be suggested. Starting in DataLoaded does not work well for calling from another script use case.
- In the timers event code you also used a CurrentBar check, however that is outside the trigger custom event so that will not work, that should be removed or moved into the screenshot code.
When called from code, you need to avoid starting the timer and also pass in the ChartControl. To expose the method you just need to make it public:
Code:private void triggerScreenshot(object price)
Code:public void triggerScreenshot(object price)
Code:public void triggerScreenshot(ChartControl cc, object price)
Code:cc.Dispatcher.InvokeAsync((Action)(() => chart = Window.GetWindow(cc) as Chart; //you will need to add this part into your method to get the chart when requested
Code:ScreenshotTakerExample().triggerScreenshot(ChartControl, Close[0]);
JesseNinjaTrader Customer Service
Comment
-
what you proposed is wonderful. Now i have a different issue. I am calling the screenshot from 2 differnet strategies and i find that the trades plotted by both strategies are on the same chart as you can see in the attached image.
in this case, i have 2 charts for eurusd. i have 1 strategy on each of the chart but the trades are printed for both of them on both the charts. is there a way, i can show only trades belonging to the strategy running on first chart not to show up on the second chart?1 Photo
Comment
-
Hello junkone,
Can you provide the script as you have it now for me to review?
As a test, can you check if this is related to the selected account in the chart? In the control center accounts tab, create a new sim account by right clicking -> add simulation account. Click OK then apply the second strategy to the second sim account, so one on each account. In each chart, open the chart trader and select the sim account that the strategy will be applied to.
After the orders happen where you see the combined image normally, does it still happen when using separate accounts? As a guess this may relate to the Chart and its selected account.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ZSortex, Today, 02:48 PM
|
0 responses
3 views
0 likes
|
Last Post
by ZSortex
Today, 02:48 PM
|
||
Started by samish18, Today, 08:57 AM
|
6 responses
20 views
0 likes
|
Last Post
by samish18
Today, 02:39 PM
|
||
Started by DanielSanMartin, Today, 02:37 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:37 PM | ||
Started by The_Sec, Yesterday, 02:29 PM
|
2 responses
12 views
0 likes
|
Last Post
by The_Sec
Today, 02:30 PM
|
||
Started by love2code2trade, Today, 01:45 PM
|
1 response
10 views
0 likes
|
Last Post Today, 02:10 PM |
Comment