Hi Jorge,
I think the method is described well in the post I mentioned earlier:
sam.nrel.gov/forum/forum-general/3583
.
This screenshot illustrates the process described in that post:
If you choose one of the automated dispatch options on the Battery Dispatch page, the battery responds to the time series price data.
The battery only charges from the grid if you check
Battery can charge from grid on the Battery Dispatch input page. In general SAM charges from the system before charging from the grid. You can verify the charging behavior by looking at the time series data on the Results page Data Tables or Time Series tabs, for example the "Electricity to battery from grid" and "Electricity to battery from system" variables.
Best regards,
Paul.